package team.fivez.defaultmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import team.fivez.defaultmanage.domain.Applicant;
import team.fivez.defaultmanage.domain.Result;
import team.fivez.defaultmanage.service.ApplicantService;
import team.fivez.defaultmanage.utils.Utils;

import java.security.NoSuchAlgorithmException;

@CrossOrigin
@RestController
@RequestMapping("/applicant")
public class ApplicantController {

    private final ApplicantService applicantService;

    @Autowired
    public ApplicantController(ApplicantService applicantService) {
        this.applicantService = applicantService;
    }

    @PostMapping("/login")//登录
    public Result applicantLogin(@RequestBody Applicant applicant) throws NoSuchAlgorithmException {
        System.out.println(applicant);
        return Utils.success(applicantService.login(applicant));
    }

    @PostMapping("/register")//注册
    public Result applicantRegister(@RequestBody Applicant applicant) throws NoSuchAlgorithmException {
        return Utils.success(applicantService.register(applicant));
    }



}
